/**
 * 项目名称:
 *
 * @Author: 夏国倩
 * @Date: 2023/9/26 10:18
 * @Copyright
 */
package Map;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class test1 {
    public static void main(String[] args) {
        String str="I love you not because of who you are,but because of who I am when I am with you";
        Set<String> set=new HashSet<>();
        for (char c:str.toCharArray()){
            set.add(String.valueOf(c));
        }
        System.out.println(set);
        System.out.println(Arrays.toString(show(set,str)));
    }
    public static int[] show(Set<String> set,String str) {
        int count[] = new int[set.size()];
        int i = 0;
        for (String o : set) {
            for (char c : str.toCharArray()) {
                if (o.equals(String.valueOf(c))) {
                    count[i]++;
                }
            }
            i++;
        }
        return count;
    }
}
